{% assign version = page.url | remove_first: "/" | split: "/" | first %}
{% assign upgrading = false %}
{% if version == '' or version == 'releases' or version == 'upgrading' %}
    {% assign version = site.data.project.releases.current.version %}
    {% assign upgrading = true %}
{% endif %}
{% capture version_home %}/{{ version }}/{% endcapture %}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="docsearch:version" content="4.0">
    <meta name="description" content="{{ site.data.project.description }}">
    <title>{{ page.title }} - {{ site.data.project.title }}</title>
    <link rel="icon" type="image/x-icon" href="//theme.thephpleague.com/img/favicon.ico" />
    <link rel="apple-touch-icon-precomposed" href="//theme.thephpleague.com/img/apple-touch-icon-precomposed.png">
    <link rel="stylesheet" href="//theme.thephpleague.com/css/all.css?2">
    <link rel="stylesheet" href="/custom.css?29">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
    <script async src="https://www.googletagmanager.com/gtag/js?id={{  site.data.project.google_analytics_tracking_id }}"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag() { dataLayer.push(arguments);}
        gtag('js', new Date());
        gtag('config', '{{  site.data.project.google_analytics_tracking_id }}');
    </script>
</head>
<body>
<header>
    <div class="header-content">
        <h1 class="title"><a href="/"><span>League</span>{{ site.data.project.title }}</a></h1>
        <div class="search"><input type="search" id="doc-search" placeholder="search the docs..."></div>
        <nav class="versions">
            <h2>{% if upgrading == true %}Notes{% else %}v{{ version }}{% endif %} &#9662;</h2>
            <ul>
                {% for v in site.data.menu.version %}
                <li {% if version == v[0] and upgrading == false %}class="selected"{% endif %}><a href="/{{ v[0] }}/">v{{ v[0] }}</a></li>
                {% endfor %}
                <li {% if upgrading == true %}class="selected"{% endif %}><a href="/releases/">Notes</a></li>
            </ul>
        </nav>
    </div>
</header>

<input type="checkbox" id="menu">
<label for="menu" onclick>
    <div class="closed">&#9776;</div>
    <div class="open">&#10799;</div>
</label>

<main>
    <menu>
        <div class="versions-small">
        <h2>Versions</h2>
            <ul>
        {% for v in site.data.menu.version %}
                <li {% if version == v[0] and upgrading == false %}class="selected"{% endif %}>
                    <a href="/{{ v[0] }}/">{{ v[0] }}</a>
                </li>
        {% endfor %}
                <li {% if upgrading == true %}class="selected"{% endif %}><a href="/releases/">Notes</a></li>
            </ul>
        </div>

        {% if upgrading == false %}
            {% for section in site.data.menu.version[version] %}
            <div class="menu-section">
                <h2>{{ section[0] }}</h2>
                <ul>
                    {% for link in section[1] %}
                        <li {% if page.url == link[1] %}class="selected"{% endif %}>
                            <a href="{{ link[1] }}">{{ link[0] }}</a>
                        </li>
                    {% endfor %}
                </ul>
            </div>
            {% endfor %}
        {% else %}
            {% for section in site.data.menu.upgrading %}
                <h2>{{ section[0] }}</h2>
                <ul>
                    {% for link in section[1] %}
                        <li {% if page.url == link[1] %}class="selected"{% endif %}>
                            <a href="{{ link[1] }}">{{ link[0] }}</a>
                        </li>
                    {% endfor %}
                </ul>
            {% endfor %}
        {% endif %}
    </menu>
    <article>
    {% if version == site.data.project.releases.next.version %}
        <p class="message-notice">This is the documentation for the upcoming <code>version {{ version }}</code>. This is a work in progress</p>
    {% endif %}

    {% if version == site.data.project.releases.previous.version %}
        <p class="message-notice">This is the documentation for <code>version {{ version }}</code> which will be supported until <strong>{{ site.data.project.releases.previous.supported_until }}</strong>. Please consider upgrading your code to <a href="{{ site.data.project.releases.current.documentation_link }}">the latest stable version</a></p>
    {% endif %}

    {% if version == site.data.project.releases.legacy.version %}
        <p class="message-notice">This is the documentation for the unsupported <code>version {{ version }}</code>. Please consider upgrading your code to <a href="{{ site.data.project.releases.current.documentation_link }}">the latest stable version</a></p>
    {% endif %}

        {{ content }}
    </article>
</main>

<aside class="sponsors hide">
    <p>Love this package ? <a href="https://github.com/sponsors/{{ site.data.project.author.github_account }}">Support its development!</a></p>
</aside>

<footer>
    <span>&copy; Copyright <a href="//thephpleague.com">The League of Extraordinary Packages</a>.</span>
    <span>Site design by <a href="//reinink.ca">Jonathan Reinink</a> and <a href="//nyamsprod.com">Ignace Nyamagana Butera</a>.</span>
</footer>
<script src="/custom.js?7"></script>
<script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<script> docsearch({
    apiKey: '63ba748e8f5bceb91934667c118972d0',
    indexName: 'thephpleague_csv',
    inputSelector: '#doc-search',
    algoliaOptions: { 'facetFilters': ["version:{{ version }}"] },
    debug: false // Set debug to true if you want to inspect the dropdown
});
</script>
</body>
</html>
